//
//  CLLMessageBarTool.m
//  AnimationRecommend
//
//  Created by 花花蔡 on 2017/2/16.
//  Copyright © 2017年 ljm. All rights reserved.
//

#import "CLLMessageBarTool.h"

@interface CLLMessageBarTool()<TWMessageBarStyleSheet>


@end

@implementation CLLMessageBarTool


+ (instancetype)shareTool {
    static CLLMessageBarTool *instance;
    
    static dispatch_once_t onceToken;
    dispatch_once(&onceToken, ^{
        instance = (CLLMessageBarTool *)[super sharedInstance];
        instance.styleSheet = instance;
    });
    
    return instance;
}

#pragma mark - 背景颜色

- (UIColor *)backgroundColorForMessageType:(TWMessageBarMessageType)type {
    
    UIColor *backgroundColor = nil;
    switch (type)
    {
        case TWMessageBarMessageTypeError:
            backgroundColor = [UIColor colorWithRed:1.0 green:0.0 blue:0.0 alpha:0.55];
            break;
        case TWMessageBarMessageTypeSuccess:
            backgroundColor = [UIColor whiteColor];
            //[UIColor colorWithRed:0.0 green:1.0 blue:0.0 alpha:0.75];
            break;
        case TWMessageBarMessageTypeInfo:
            backgroundColor = [UIColor colorWithRed:68/255.0 green:96/255.0 blue:133/255.0 alpha:0.75];
            
            break;
        default:
            break;
    }
    return backgroundColor;
    
}

- (UIColor *)strokeColorForMessageType:(TWMessageBarMessageType)type {
    
    UIColor *strokeColor = nil;
    switch (type)
    {
        case TWMessageBarMessageTypeError:
            strokeColor = [UIColor colorWithRed:1.0 green:0.0 blue:0.0 alpha:0.75];;
            break;
        case TWMessageBarMessageTypeSuccess:
            strokeColor = [UIColor whiteColor];
            //[UIColor colorWithRed:0.0 green:1.0 blue:0.0 alpha:1.0];
            break;
        case TWMessageBarMessageTypeInfo:
            strokeColor = [UIColor colorWithRed:68/255.0 green:96/255.0 blue:133/255.0 alpha:0.75];
            break;
        default:
            break;
    }
    return strokeColor;
}

- (UIImage *)iconImageForMessageType:(TWMessageBarMessageType)type {
    UIImage *image = nil;
    
    switch (type) {
        case TWMessageBarMessageTypeError:
            image = [UIImage imageNamed:@"icon-error"];
            break;
        case TWMessageBarMessageTypeInfo:
            image = [UIImage imageNamed:@"icon-info"];
            break;
        case TWMessageBarMessageTypeSuccess:
            image = [UIImage imageNamed:@"成功"];
            break;
        default:
            break;
    }
    
    return image;
}

- (UIColor *)titleColorForMessageType:(TWMessageBarMessageType)type {
    UIColor *fontColor = nil;
    switch (type) {
        case TWMessageBarMessageTypeSuccess:
            fontColor = [UIColor blackColor];
            break;
        case TWMessageBarMessageTypeError:
            fontColor = [UIColor whiteColor];
            break;
        case TWMessageBarMessageTypeInfo:
            fontColor = [UIColor whiteColor];
            break;
        default:
            break;
    }
    
    return fontColor;
}

- (UIFont *)titleFontForMessageType:(TWMessageBarMessageType)type {
    
    UIFont *font = [UIFont fontWithName:ManYu_FontStr size:18.f];
    return font;
}

- (UIFont *)descriptionFontForMessageType:(TWMessageBarMessageType)type {
    return ManYu_Font;
}

- (UIColor *)descriptionColorForMessageType:(TWMessageBarMessageType)type {
    
    UIColor *fontColor = nil;
    switch (type) {
        case TWMessageBarMessageTypeSuccess:
            fontColor = [UIColor blackColor];
            break;
        case TWMessageBarMessageTypeError:
            fontColor = [UIColor whiteColor];
            break;
        case TWMessageBarMessageTypeInfo:
            fontColor = [UIColor whiteColor];
            break;
        default:
            break;
    }
    
    return fontColor;
}

#pragma mark - 自定义方法

+(void)showMessageWithType:(TWMessageBarMessageType)type WithTitle:(NSString *)title WithDescription:(NSString *)description {
    [[CLLMessageBarTool shareTool] showMessageWithTitle:title description:description type:type];
}

//- (void)showErrorWithTitle:(NSString *)title WithDescription:(NSString *)description{
//    
//    [[CLLMessageBarTool shareTool] showMessageWithTitle:title description:description type:TWMessageBarMessageTypeError];
//}
//
//- (void)showInfoWithTitle:(NSString *)title WithDescription:(NSString *)description {
//    
//    [[CLLMessageBarTool shareTool] showMessageWithTitle:title description:description type:TWMessageBarMessageTypeInfo];
//}
//
//- (void)showSuccessWithTitle:(NSString *)title WithDescription:(NSString *)description {
//    [[CLLMessageBarTool shareTool] showMessageWithTitle:title description:description type:TWMessageBarMessageTypeSuccess];
//}




@end
